/**
 * @summary plug
 */
import * as multer from 'multer';

/**
 * @class upload
 */
class Upload {
    public static storage: multer.StorageEngine;
    public static upload() {
        this.storage = multer.diskStorage({
            destination: 'public/upload',
            filename: function (req, file, callback): void {
                console.log('file', file);
                var fileFormat = (file.originalname).split('.');
                var filename = new Date().getTime();
                callback(null, filename+"."+fileFormat[fileFormat.length-1]);
            }
        });
        return multer({storage: this.storage});
    }
}

export default Upload;